<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE html>
<html>

<head>
<base href="<%=basePath%>">
<meta charset="UTF-8">
<title></title>

<!--[if lt IE 9]>
<script src="<%=basePath%>js/jquery-1.11.3.js"></script>    
<![endif]-->
<!--[if gte IE 9]><!-->
<script src="<%=basePath%>js/jquery-3.1.1.js"></script>
<!--<![endif]-->
<script>
  function bt1click(){	  
	  vurl = "<%=basePath%>s/ajax";

		$.get(vurl, function(result, status) {
				obj=JSON.parse(result)
				//$("#div1").html(obj.length);
			//	for (v=0;v<obj.length;v++) {
				for (v in obj) {
					var data = obj[v];
					$("#div1").find('ul').append(
							'<li> name=' + data.name + ' ,price  ' + data.name
									+ '</a></li>');
				}

		});

		/* $.ajax({
			url : vurl,
			success : function(result) {
				
				obj=JSON.parse(result)
				//$("#div1").html(obj.length);
			//	for (v=0;v<obj.length;v++) {
				for (v in obj) {
					var data = obj[v];
					$("#div1").find('ul').append(
							'<li> name=' + data.name + ' ,price  ' + data.name
									+ '</a></li>');
				}

			}
		}); */
	}
</script>
</head>

<body>
	<div id="div1">
		<ul></ul>
	</div>
	<button onclick="bt1click()">按一下 请求 servlet json</button>
	<form>
		<input type="text" name="name" id="name" value="" />
	</form>
</body>

</html>